<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link href='../packages/bundle/main.css' rel='stylesheet' />
<script src='../packages/bundle/main.js'></script>
<script src='../node_modules/jquery/dist/jquery.min.js'></script>
<script>

  // The jQuery Connector
  // ----------------------------------------------------------------------------------------------------

  $.fn.fullCalendar = function(options) {
    var args = Array.prototype.slice.call(arguments, 1) // for a possible method call
    var res = this // what this function will return (the current jQuery object by default)

    this.each(function(i, el) { // loop each DOM element involved
      var $el = $(el)
      var calendar = $el.data('fullCalendar') // get the existing calendar object (if any)
      var singleRes // the returned value of this single method call

      // a method call
      if (typeof options === 'string') {

        if (options === 'getCalendar') {

          if (!i) { // first element only
            res = calendar
          }

        } else if (options === 'destroy') { // don't warn if no calendar object

          if (calendar) {
            calendar.destroy()
            $el.removeData('fullCalendar')
          }

        } else if (!calendar) {

          console.warn('Attempting to call a FullCalendar method on an element with no calendar.')

        } else if ($.isFunction(calendar[options])) {

          singleRes = calendar[options].apply(calendar, args)

          if (!i) {
            res = singleRes // record the first method call result
          }

        } else {
          console.warn("'" + options + "' is an unknown FullCalendar method.")
        }

      // an initialization
      } else {

        if (calendar) {
          console.warn('Can\'t initialize another calendar on the same element.')
        } else {
          calendar = new FullCalendar.Calendar(el, options)
          $el.data('fullCalendar', calendar)
          calendar.render()
        }
      }
    })

    return res
  }


  // The Actual Example
  // ----------------------------------------------------------------------------------------------------

  $(document).ready(function() {
    var $calendar = $('#calendar')

    $calendar.fullCalendar({
      headerToolbar: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
      },
      initialDate: '2020-09-12',
      navLinks: true, // can click day/week names to navigate views
      editable: true,
      dayMaxEvents: true, // allow "more" link when too many events
      events: [
        {
          title: 'All Day Event',
          start: '2020-09-01',
        },
        {
          title: 'Long Event',
          start: '2020-09-07',
          end: '2020-09-10'
        },
        {
          groupId: 999,
          title: 'Repeating Event',
          start: '2020-09-09T16:00:00'
        },
        {
          groupId: 999,
          title: 'Repeating Event',
          start: '2020-09-16T16:00:00'
        },
        {
          title: 'Conference',
          start: '2020-09-11',
          end: '2020-09-13'
        },
        {
          title: 'Meeting',
          start: '2020-09-12T10:30:00',
          end: '2020-09-12T12:30:00'
        },
        {
          title: 'Lunch',
          start: '2020-09-12T12:00:00'
        },
        {
          title: 'Meeting',
          start: '2020-09-12T14:30:00'
        },
        {
          title: 'Happy Hour',
          start: '2020-09-12T17:30:00'
        },
        {
          title: 'Dinner',
          start: '2020-09-12T20:00:00'
        },
        {
          title: 'Birthday Party',
          start: '2020-09-13T07:00:00'
        },
        {
          title: 'Click for Google',
          url: 'http://google.com/',
          start: '2020-09-28'
        }
      ]
    })

    $('#prev-button').on('click', function() {
      $calendar.fullCalendar('prev')
    })

    $('#next-button').on('click', function() {
      $calendar.fullCalendar('next')
    })

    $('#gotoDate-button').on('click', function() {
      $calendar.fullCalendar('gotoDate', '2020-09-01')
    })
  })

</script>
<style>

  body {
    margin: 40px 10px;
    padding: 0;
    font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
    font-size: 14px;
  }

  #calendar {
    max-width: 1100px;
    margin: 0 auto;
  }

</style>
</head>
<body>

  <button id='prev-button'>prev</button>
  <button id='next-button'>next</button>
  <button id='gotoDate-button'>goto year 2000</button>

  <div id='calendar'></div>

</body>
</html>
